#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include "field.h"
#include "table.h"
#include "debug-inl.h"
struct tag {
    char *name;
    char *id;
    int type;
};

int main(int argc, char **argv)
{
    char input[102400];
    FILE *fp = fopen(argv[1], "r+");
    size_t len = 0;
    struct table *t;
    struct field *f;
    unsigned char *data = malloc(102400);
    FILE *fp_data = fopen(argv[2], "r+");

    memset(input, 0, sizeof(input));
    if (fp == NULL) {
        err_print("open html file fail.\n");
    }
    len = fread(input, 1, sizeof(input), fp);
    printf("len=%d\n", len);
    printf("data==%p\n", data);
    len = fread(data, 1, sizeof(input)-1, fp_data);

   t = table_get_from_html(input);
   f = table_to_fields(t);
   field_show(f);
   parse_data_by_fields(f, &data);
   //table_show(t);
   fclose(fp);
   fclose(fp_data);
   return 0;
}

